﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using Catering.View_Operaction;

namespace Catering
{
    public class UserIsNull : System.Web.UI.Page
    {
        public bool Base_IsAdmin = false;
        public int Base_Companyid = 0;
        public int Base_Groupid = 0;
        public int Base_Classid = 0;
        public Catering_Model.E_Personnel LoginPersonnel=new Catering_Model.E_Personnel(); 

        protected override void OnLoad(EventArgs e)
        {
            if (Session["RoleID"] == null || Session["RoleID"].ToString() == "")
            {
                Response.Write("<script language='javascript'>window.top.location.href='/loginOut.aspx';</script>");
                Response.End();
            }
            else
            {
                Hashtable ht = (Hashtable)Application["UsersCount"];
                ht.Remove(Session["key"].ToString());
                string str = Session["UserID"].ToString();
                LoginPersonnel = new Catering_Rules.T_Personnel().GetModel(int.Parse(str));
                LoginPersonnel.AreaID=new Catering_Rules.ClassInfo().GetModel(LoginPersonnel.ClassID).AID; //区域ID
                LoginPersonnel.RoleID = int.Parse(Session["RoleID"].ToString());//角色ID
                Catering_Model.Role eRole = new Catering_Rules.Role().GetModel(LoginPersonnel.RoleID);
                LoginPersonnel.RoleName = (eRole != null) ? eRole.RoleName : ""; //角色名称
                Session["UserInfo"] = LoginPersonnel;
                Session["key"] = str;
                ht.Add(str, Session["User"].ToString() + "," + DateTime.Now.ToString());
                if (Session["PersonnelID"] != null)
                {
                    Bind_Data_to_Controls.GetCompanyByCurrentUser(Session["PersonnelID"].ToString(), out Base_Companyid, out Base_Groupid, out Base_Classid, out Base_IsAdmin);
                }
            }
            base.OnLoad(e);
        }
    }
}